JavaScript also contains a conditional operator that assigns a value to a variable based on some condition.
variablename=(condition)?value1:value2 |
greeting=(visitor=="PRES")?"Dear President ":"Dear " |
If the variable visitor is equal to PRES, then put the string "Dear President " in the variable named greeting. If the variable visitor is not equal to PRES, then put the string "Dear " into the variable named greeting
#Title: Conditional Statements
#Element: 171: Conditional Statements